package org.myorg.v3;


import java.io.Serializable;
import java.util.Random;

public class FGene3 extends Gene3 implements Serializable {
	int length;
	public double gene[];
	
	
	public FGene3() {
		length = 0;
	}

	/**
	 * 
	 * @param length the length of gene
	 * @param low low value of gene
	 * @param high high value of gene
	 */
	public FGene3(int length) {
		this.length = length;
		this.gene = new double[length];
		
		for(int i = 0; i < length; i++) {
			gene[i] = Math.random();
		}
	}
	
	public FGene3(FGene3 gene) {
		this.gene = gene.getGene().clone();
		this.length = gene.getLength();
		this.fitness = gene.fitness;
	}

	public int getLength() {
		return length;
	}

	public double[] getGene() {
		return gene;
	}
	public double getFitness() {
		return fitness;
	}

	public void setFitness(double fitness) {
		this.fitness = fitness;
	}
	
/*	public double[] getGene(int begin) {
		double res[] = new double[length-begin];
		for (int i= 0; i < length-begin; i++) {
			res[i] = gene[begin+i];
		}
		return res;
	}
	
	public double[] getGene(int begin,int end) {
		double res[] = new double[end-begin];
		for (int i= 0; i < end-begin; i++) {
			res[i] = gene[begin+i];
		}
		return res;
	}*/
	
	public double geneAt(int pos) {
		return gene[pos];
	}
	
	public void setGene(int pos, double value) {
		gene[pos] = value;
	}
	
}

